package com.woniuxy.meal.controller;


import cn.hutool.core.io.FileUtil;
import com.woniuxy.meal.common.Result;
import com.woniuxy.meal.config.GetTypeByHead;
import com.woniuxy.meal.entity.FoodVariety;
import com.woniuxy.meal.form.FoodVarietySearchForm;
import com.woniuxy.meal.service.FoodVarietyService;
import com.woniuxy.meal.service.dto.FoodVarietyDto;
import com.woniuxy.meal.service.dto.WoniuPageDto;
import com.woniuxy.meal.util.OSSUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.io.InputStream;
import java.util.UUID;

/**
 * <p>
 * 菜品 前端控制器
 * </p>
 *
 * @author zz
 * @since 2023年06月16日
 */
@RestController
@RequestMapping("/foodVariety")
@Api(tags = "菜品相关接口")
public class FoodVarietyController {

    @Autowired
    private FoodVarietyService service;


    @ApiOperation("按条件展示商铺所有菜品")
    @PostMapping("/search")
    public Result search(@Valid @RequestBody FoodVarietySearchForm form){
        WoniuPageDto pageDto = service.searchByCondition(form);
        return Result.success(200,"查询所有该商品菜品成功",pageDto);
    }

    @ApiOperation("根据类型查询")
    @GetMapping("/searchByType")
    public Result searchByType(Integer typeId){
        WoniuPageDto pageDto = service.searchByType(typeId);
        return Result.success(200,"查询所有该商品菜品成功",pageDto);
    }


    @ApiModelProperty("菜品详情页")
    @PostMapping("/info")
    public Result getFoodInfo(Long id){
        FoodVarietyDto foodVarietyDto = service.getFoodInfo(id);
        return Result.success(200,"查询菜品详情成功",foodVarietyDto);

    }






}

